package demo1;

import java.util.Arrays;

public class Test {

    //默认年龄比
    public static void main(String[] args) {
        Student[] students = new Student[2];
        students[0] = new Student("bn",18,80);
        students[1] = new Student("ai",88,20);

        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
    }


    //根据姓名比
    public static void main3(String[] args) {

        Student[] students = new Student[2];
        students[0] = new Student("bn",90,18);
        students[1] = new Student("ai",88,20);

        NameCompator nameCompator = new NameCompator();

        Arrays.sort(students,nameCompator);
        System.out.println(Arrays.toString(students));
    }



    public static void main2(String[] args) {
        Student student1 = new Student("zahngsan",90,18);
        Student student2 = new Student("lisi",88,20);

        AgeComparable ageComparable = new AgeComparable();
        int ret = ageComparable.compare(student1,student2);
        System.out.println(ret);
    }


    public static void main1(String[] args) {

        Student student1 = new Student("zahngsan",90,18);
        Student student2 = new Student("lisi",88,20);

        if(student1 .compareTo(student2) > 0){
            System.out.println("student1 > student2");
        }else {
            System.out.println("student1 < student2");
        }
    }
}
